#include <iostream>
using namespace std;

int x,y,xs,ys,a=0,b=0,c=0,d=0;
int main()
{
    int T,n,m,maxLen=0;
    scanf("%d",&T);
    while(T--)
    {
        maxLen=0;
        a = b = c = d = -0x3f3f3f3f;
        scanf("%d",&n);
        while(n--)
        {
            scanf("%d%d",&x,&y);
            a = max(a,x+y);
            b = max(b,-1*x-y);
            c = max(c,x-y);
            d = max(d,y-x);
        }
        scanf("%d",&m);
        while(m--)
        {
            maxLen  = 0;
            scanf("%d %d",&xs,&ys);
            maxLen = max(maxLen,a-xs-ys);
            maxLen = max(maxLen,b+xs+ys);
            maxLen = max(maxLen,c-xs+ys);
            maxLen = max(maxLen,d+xs-ys);
            printf("%d\n",maxLen);
        }
    }
    return 0;
}
